﻿using System;
using System.Windows.Forms;
using ZFGK.Addins;
using ZFGK.Definition;
using ZFGK.OSG.UI.Commands;
using ZFGK.WinForms.Forms;
using ZfPlatform.DevExpressGUI;

namespace OSS.ModelViewer.Commands.TestCmds
{
    public class AddTestCmd : IExtendCommand
    {
        public static bool bAdd = false;
        public CmdResult Execute(ExtendCmdData cmdData, ref string message)
        {
            var mainRibbonForm = cmdData.MainForm as MainRibbonForm;
            var computerName = System.Environment.GetEnvironmentVariable("ComputerName");
            if (!bAdd && string.Compare(computerName, "TianTeng-PC", StringComparison.CurrentCultureIgnoreCase) != 0
                && string.Compare(computerName, "TianTeng-Zhifan", StringComparison.CurrentCultureIgnoreCase) != 0
                && string.Compare(computerName, "liao-PC", StringComparison.CurrentCultureIgnoreCase) != 0)
            {
                var inputOneValForm = new InputOneValForm("测试功能密码", RegexType.Custom);
                if (inputOneValForm.ShowDialog(mainRibbonForm) != DialogResult.OK
                    || inputOneValForm.InputValue != "1234")
                    return CmdResult.Cancel;
            }

            var addinService = AddinManager.AddinService;
            addinService.RegisterCmd<AutoTransformTestCmd>();
            addinService.RegisterCmd<TestVideoCmd>();
            addinService.RegisterCmd<TestTexture2DCmd>();
            addinService.RegisterCmd<OsgTianTengTestCmd>();
            bAdd = true;

            return CmdResult.Succeed;
        }
    }
}
